def song_decoder(song):
    return song.replace('WUB', ' ').replace(" ")

# # 1.5.4 try-except-finally的使用
# try:
#     num = "50"
#     print(num/2)
# except TypeError as e:
#     print("捕获到异常：", e)
# finally:
#     print("无论是否发生异常，这里都会执行")

# # 1.5.5 多个except的使用
# try:
#     num = "50"
#     print(num / 2)
# except TypeError as e:
#     print("捕获到的字符串与数字数学运算的异常：", e)
# except ZeroDivisionError as e:
#     print("捕获到的除数为0的异常", e)
# finally:
#     print("无论是否发生异常，这里都会执行")

# # 1.5.6 多个except的使用
# try:
#     num = 50
#     print(num / 0)
# except (TypeError, ZeroDivisionError) as e:
#     print("捕获到的字符串与数字数学运算的异常：", e)
# finally:
#     print("无论是否发生异常，这里都会执行")

# # 1.5.7 捕获所有异常
# try:
#     num = 50
#     print(num / 0)
# except:
#     print("捕获到的任意异常：")
# finally:
#     print("无论是否发生异常，这里都会执行")

# 1.5.8 捕获所有异常
# try:
#     num = 50
#     print(num / 0)
# except BaseException as e:
#     print("捕获到的任意异常：", e)
# finally:
#     print("无论是否发生异常，这里都会执行")

# 1.6.2 Python中定义一个类
class Student(object):
    def __init__(self, name, age, grade):
        self.name = name
        self.age = age
        self.grade = grade

    def study(self):
        print(self.name+"在学习基础知识")


# baseStudent = Student("学生0", 10, 3)
# print("baseStudent的name:", baseStudent.name)
# print("baseStudent的age:", baseStudent.age)
# print("baseStudent的grade:", baseStudent.grade)
# baseStudent.study()


class PrimaryStudent(Student):
    def study(self):
        print(self.name+"在学习小学知识")


class JuniorStudent(Student):
    def study(self):
        print(self.name+"在学习初中知识")


primaryStudent = PrimaryStudent("小学生", 7, 1)
print("primaryStudent的name:", primaryStudent.name)
print("primaryStudent的age:", primaryStudent.age)
print("primaryStudent的grade:", primaryStudent.grade)
primaryStudent.study()

juniorStudent = JuniorStudent("小学生", 13, 7)
print("juniorStudent的name:", juniorStudent.name)
print("juniorStudent的age:", juniorStudent.age)
print("juniorStudent的grade:", juniorStudent.grade)
juniorStudent.study()
